package com.yy.device.core.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yy.device.core.entity.Task;
import com.yy.device.core.mapper.TaskMapper;
import com.yy.device.core.service.TaskService;
import com.yy.device.enums.DeviceExeTaskStatus;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 用户信息表 服务实现类
 * </p>
 *
 * @author 孙志强
 * @since 2020-04-13
 */
@Service
public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements TaskService {
    @Override
    public Task findNewByTaskId(long taskId) {

//        LambdaQueryWrapper<Task> wrapper = new LambdaQueryWrapper<>();
//        wrapper.eq(Task::getTaskId, taskId)
//                .eq(Task::getExeStatus, DeviceExeTaskStatus.NEW.name());

        QueryWrapper<Task> wrapper = new QueryWrapper<>();
        wrapper.eq("task_id", taskId)
                .eq("exe_status", DeviceExeTaskStatus.NEW.name());

        return baseMapper.selectOne(wrapper);
    }

    @Override
    public List<Task> findNewTaskList() {
        LambdaQueryWrapper<Task> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Task::getExeStatus, DeviceExeTaskStatus.NEW.name());
        return baseMapper.selectList(wrapper);
    }
}
